-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ensure posix path sep is used #728
Conversation
const relativePath = path | ||
.relative(opsGenDirectory, generatedFileName) | ||
// ensure posix path separators are used | ||
.split(path.win32.sep) | ||
.join(path.posix.sep); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is OK. But, is there any possibility that this affects any other downstream consumers of the relativePath
in unintended (negative) ways?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All path
and fs
functions accept posix style paths even on a windows machine. So I think it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e.
> path.resolve('./packages/graphql-generator/package.json')
D:\\Users\\dppilche\\amplify-codegen\\packages\\graphql-generator\\package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more so wondering if we do any path splitting or merging that could break due to it looking for os delimiting.
Description of changes
Alternative to #727
See https://github.com/aws-amplify/amplify-cli/issues/13289 for details.
path.relative
behaves differently on windows. https://nodejs.org/api/path.html#pathrelativefrom-toThis results in the generated path being invalid syntax in TypeScript/JavaScript.
This change replaces the windows path separator (
path.win32.sep
) with the posix path separator (path.posix.sep
).Issue #, if available
https://github.com/aws-amplify/amplify-cli/issues/13289
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.